var getEById = function (eleId) {
    return document['getElementById'](eleId);
};
String['prototype']['GetPart'] = function (_0xb2fdx3) {
    var _0xb2fdx4 = new RegExp('(^|&)' + _0xb2fdx3 + '=([^&]*)(&|$)');
    var _0xb2fdx5 = this['substr'](this['indexOf']('?') + 1)['match'](_0xb2fdx4);
    if (_0xb2fdx5 != null) {
        return unescape(_0xb2fdx5[2]);
    };
    return null;
};

function ANCMedia() {
    _lg = szk['id']['logo'];
    dl = szk['id']['link'];
    pl = szk['id']['player'];
    tp = szk['id']['sv'];
    playing = szk['id']['dx'];
    home = szk['id']['home'];

    function getData() {
        m_data = getEById(dl)['innerHTML'];
        r_left = '<div id="r_data" style="display:none !important;" title="Data here !">';
        r_right = '</div>';
        m_data = m_data['replace'](/\<id\>/gi, r_left);
        m_data = m_data['replace'](/\<\/id\>/gi, r_right);
        m_data = m_data['replace'](/\[id\]/gi, r_left);
        m_data = m_data['replace'](/\[\/id\]/gi, r_right);
        getEById(dl)['innerHTML'] = m_data;
        m_data = getEById('r_data')['innerHTML'];
        return m_data;
    };
    data = getData();
    l_spi = data['split']('|')['length'];
    l_spk = function (eleId) {
        return data['split']('|')[eleId]['split'](';')['length'];
    };
    d_spi = function (eleId) {
        return data['split']('|')[eleId];
    };
    d_spk = function (eleId, _0xb2fdx8) {
        return data['split']('|')[eleId]['split'](';')[_0xb2fdx8];
    };
    part = new Array();
    pc = ['0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's'];
    ab = '';
    part_ep = '';
    data_out = '';
    svl = 'youtube.com,anc.yl,anc.mp4,anc.flv,megafun.vn,phimvang.org,you.bay68,ps1.bay68,ps2.bay68,ps3.bay68,picasaweb.google.com,dailymotion.com,zing.vn,4shared.com,clip.vn,videobb.com,videozer.com,zippyshare.com,novamov.com,twitvid.com,cyworld.vn,24video.net,movshare.net,veoh.com,blip.tv,sendspace.com,speedyshare.com,rolo.vn,tunescoop.com,eyvx.com,banbe.net,truongxua.vn,videobam.com,nhaccuatui.com,mediafire.com,vimeo.com,viddler.com,vidxden.com,xvideos.com,free18.net,nuvid.com,youjizz.com,eporner.com,gaytube.com,megafilex.com,porn.com,pornhub.com,pornoxo.com,redtube.com,slutload.com,spankwire.com,tnaflix.com,tube8.com,vtraxe.com,xhamster.com,xtube.com,xxxstash.com';
    svt = 'Youtube,Gdata,MP4,FLV,Megafun,Phimvang,VietNam,VIP,Dream,Bay68,Picasa,Daily,Zing,4shared,Clip,Videobb,Videozer,Zippyshare,Novamov,Twitvid,Cyworld,24video,Movshare,Veoh,Blip,Sendspace,Speedyshare,Rolo,Tunescoop,Eyvx,Banbe,Truongxua,Videobam,Nhaccuatui,Mediafire,Vimeo,Viddler,Vidxden,Xvideos,Free18,Nuvid,Youjizz,Eporner,Gaytube,Megafilex,Porn,Pornhub,Pornoxo,Redtube,Slutload,Spankwire,Tnaflix,Tube8,Vtraxe,Xhamster,Xtube,Xxxstash';
    sv = svl['split'](',');
    ten_sv = svt['split'](',');
    this['Play'] = function () {
        for (var j = 0; j < ten_sv['length']; j++) {
            var serverName = ten_sv[j]['split']('.')[0];
            if (serverName == '') {
                serverName = home;
            };
            part[j] = '<li class="sev">+Server ' + serverName + ':</li>';
        };
        for (var i = 0; i < l_spi; i++) {
            name_ep = d_spk(i, 0);
            for (var _0xb2fdxc = 0; _0xb2fdxc < l_spk(i); _0xb2fdxc++) {
                link_ep = d_spk(i, _0xb2fdxc);
                number_ep = Number(d_spk(i, 0));
                number_epp = '';
                if (i > 0) {
                    number_epp = Number(d_spk((i - 1), 0));
                };
                if (l_spk(i) == 2) {
                    ab = '';
                    part_ep = '';
                } else {
                    ab = pc[_0xb2fdxc];
                    part_ep = '-' + _0xb2fdxc;
                };
                (number_ep) ? name_eppart = name_ep + ab : name_eppart = name_ep + part_ep;
                if (d_spk(i, _0xb2fdxc) != '') {
                    for (var j = 0; j < sv['length']; j++) {
                        (d_spk(i, _0xb2fdxc)['indexOf'](sv[j]) != -1) ? part[j] += '<li onclick="M.Load(\'' + link_ep + '\',\'' + name_eppart + '\');" class="ep"><a class="a_tap" rel="' + home + ':' + name_eppart + '" title="' + name_eppart + '" href="?p=' + i + '/' + _0xb2fdxc + '/' + name_eppart['replace'](/ /gi, '_') + '">&nbsp;' + name_eppart + '&nbsp;</a></li><!--ANCMedia Part-->' : false;
                    };
                };
            };
        };
        data_out += '<div id="list_tap">';
        if (l_spi >= 2) {
            for (var j = 0; j < sv['length']; j++) {
                (part[j]['indexOf']('ANCMedia') != -1) ? data_out += '<ul id=\'' + j + '\'>' + part[j] + '<div style=\'clear:both;\' ></div></ul>' : false;
            };
        } else {
            data_out += '<ul><li class="sev">+Server Home:</li>' + '<li class="ep"><a class="a_tap" rel="' + home + ': Xem Full" title="Xem Full" href="javascript:M.Load(\'' + data + '\',\'Full_time\');">Xem Full</a></li></ul>';
        };
        data_out += '<div class="clear" /></div>';
        getEById(tp)['innerHTML'] = data_out;
    };
    this['Load'] = function (eleId, _0xb2fdx8) {
        obj = '';
        name_ep = '';
        if (eleId['indexOf'](sv[0]) != -1) {
            eleId = eleId['replace'](/\/watch\?v=/gi, '/v/');
            eleId = eleId['replace'](/\&feature=related/gi, '');
            obj = DBOj(eleId)[3];
        };
        if (eleId['indexOf'](sv[1]) != -1) {
            eleId = eleId['replace'](/anc\.yl/gi, 'http://www.youtube.com/p/');
            obj = DBOj(eleId)[3];
        };
        if (eleId['indexOf'](sv[2]) != -1) {
            eleId = eleId['replace'](/anc\.mp4/gi, 'http:');
            obj = DBOj(eleId)[0];
        };
        if (eleId['indexOf'](sv[3]) != -1) {
            eleId = eleId['replace'](/anc\.flv/gi, 'http:');
            obj = DBOj(eleId)[0];
        };
        if (eleId['indexOf'](sv[4]) != -1) {
            eleId = eleId['replace'](/megafun\.vn/gi, '');
            obj = DBOj(eleId)[1];
        };
        if (eleId['indexOf'](sv[5]) != -1) {
            eleId = eleId['replace'](/\.html/gi, '.xml');
            obj = DBOj(eleId)[2];
        };
        if (eleId['indexOf'](sv[6]) != -1) {
            eleId = eleId['replace'](/you\.bay68/gi, 'http://youtube.com');
            obj = DBOj(eleId)[1];
        };
        if (eleId['indexOf'](sv[7]) != -1) {
            eleId = eleId['replace'](/ps1\.bay68/gi, 'https://picasaweb.google.com');
            obj = DBOj(eleId)[1];
        };
        if (eleId['indexOf'](sv[8]) != -1) {
            eleId = eleId['replace'](/ps2\.bay68/gi, 'https://picasaweb.google.com');
            obj = DBOj(eleId)[1];
        };
        if (eleId['indexOf'](sv[9]) != -1) {
            eleId = eleId['replace'](/ps3\.bay68/gi, 'https://picasaweb.google.com');
            obj = DBOj(eleId)[1];
        };
        for (var _0xb2fdxd = 10; _0xb2fdxd < sv['length']; _0xb2fdxd++) {
            if (eleId['indexOf'](sv[_0xb2fdxd]) != -1) {
                obj = DBOj(eleId)[0];
            };
        };
        if (Number(_0xb2fdx8)) {
            name_ep = '<span>Đang xem:</span> ' + _0xb2fdx8 + '';
        } else {
            if (_0xb2fdx8['length'] >= 5) {
                name_ep = '<span>Đang xem:</span> ' + _0xb2fdx8 + '';
            } else {
                if (!Number(_0xb2fdx8) && _0xb2fdx8['length'] < 5) {
                    name_ep = '<span>Đang xem:</span> ' + _0xb2fdx8 + '';
                };
            };
        };
        if (eleId.match(/^\/[0-9]{6}/)) {
          // Fix for megafun
          obj = '<object type="application/x-shockwave-flash" data="http://megafun.vn/common/player/player.swf" width="100%" height="100%" bgcolor="#000000" id="player" name="player" tabindex="0"><param name="allowfullscreen" value="true"><param name="allowscriptaccess" value="always"><param name="seamlesstabbing" value="true"><param name="wmode" value="opaque"><param name="flashvars" value="id=player&amp;className=player&amp;image=http://chusuninfo.googlecode.com/svn/images/logo.png&amp;autostart=true&amp;stretching=uniform&amp;type=&amp;file='+eleId+'&amp;streamer=http%3A%2F%2Fs22.ctl.vsolutions.vn%2Fctl%2Fvideo%2F&amp;controlbar.position=bottom&amp;controlbar.idlehide=true"></object>';
        }
        getEById(pl)['innerHTML'] = obj;
        getEById(playing)['innerHTML'] = name_ep;
    };
    this['Qstr'] = function () {
        str = window['location']['href'];
        part = str.GetPart('p');
        (part == null) ? part = '0/1/' + d_spk(0, 0) + '' : false;
        a = part['split']('/')[0];
        b = part['split']('/')[1];
        c = decodeURI(part['split']('/')[2]);
        (l_spi >= 2) ? this.Load(d_spk(a, b), c) : this.Load(data, 'Full_time');
    };
};
var DBOj = function (eleId) {
    _em = 'type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" autostart="true" width="100%" height="100%"';
    return obj = ['<embed name="flashplayer" src="http://data.yophim.com/gk/player.swf" FlashVars="plugins=http://data.yophim.com/gk/plugins/proxy.swf&proxy.link=' + eleId + '&autostart=true&skin=http://360s.vn/phim/grab/skin.swf" ' + _em + ' />', '<embed id="player" src="http://megafun.vn/common/player/player.swf" flashvars="autostart=true&file=' + eleId + '&streamer=http://ctl.vsolutions.vn/ctl/video/?bts=Bay68&skin=http://360s.vn/phim/grab/skin.swf" ' + _em + '/>', '<embed ' + _em + ' flashvars="plugins=http://phimvang.org/player/plugins/ListBox.swf,http://phimvang.org/player/plugins/proxy.swf&proxy.list=' + eleId + '&repeat=list&autostart=true" src="http://phimvang.org/player/player.swf?logo.file=http://phimvang.org/img/logo-trans.png&logo.hide=false&logo.position=top-right&logo.margin=-1010&skin=http://phimvang.org/player/plugins/skin_full.swf" name="flashplayer"/>', '<embed src="' + eleId + '?modestbranding=1&version=3&hl=vi_VN&rel=0&autoplay=1&showsearch=0&iv_load_policy=3" ' + _em + ' allownetworking="internal"/>'];
};
M = new ANCMedia();
M.Play();
M.Qstr();